package oa.web.service;

import java.util.Iterator;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import oa.core.MySession;
import oa.web.dao.AttendDao;
import oa.web.dao.impl.SalaryDao;
import oa.web.pojo.Attend;
import oa.web.pojo.CalculateSalary;
import oa.web.pojo.Employee;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SalaryService {
	
	@Autowired SalaryDao salaryDao;
	@Autowired AttendDao attendDao;
	
	public List<Employee> getByManagerId(int managerId){
		return salaryDao.getAllEmpoyeeByManagerId(managerId);
	}
	
	public List<Attend> getPersonalAttendances(int empId, String startDay, String endDay){
		return attendDao.findByEmpAndDays(empId, startDay, endDay);
	}
	
	public int CalculatePersonalSalary(int empId, String startDay, String endDay){
		List<Attend> attendances = this.getPersonalAttendances(empId, startDay, endDay);
		CalculateSalary cal = new CalculateSalary(attendances);
		int salary = cal.getPersonSalary();
		return salary;
	}
}
